package com.drojian.singleton.type6;

import org.junit.Test;
/**
 * 静态内部类方式，推荐使用
 */
public class SingletonTest06 {
    @Test
    public void test01(){
        Singleton instance = Singleton.getInstance();
        Singleton instance2 = Singleton.getInstance();
        System.out.println(instance == instance2);
    }
}
class Singleton{
    public Singleton() {
    }
    public static class SingletonInstance{
        private static  Singleton INSTANCE = new Singleton();

    }
    public static Singleton getInstance(){
        return SingletonInstance.INSTANCE;
    }

}